package com.sl.service;

import javax.jms.Destination;
import javax.jms.Queue;
import javax.jms.Topic;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

@Service
public class Producer implements ProducerService{
	@Autowired // 也可以注入JmsMessagingTemplate对JmsTemplate进行了封装  
	 private JmsTemplate jmsTemplate;  
	 @Autowired
	 @Qualifier(value="testQueue")
	 Queue testQueue;
	 @Autowired
	 @Qualifier(value="testTopic")
	 Topic  testTopic;
	 
	@Override
	public void sendMessage(Destination destination, String message) {
		 jmsTemplate.convertAndSend(destination, message); 
	}


	@Override
	public void sendMessage(String message) {
		 jmsTemplate.convertAndSend(testQueue, message);
	}

	@Override
	public void publish(String message) {
		 jmsTemplate.convertAndSend(testTopic, message);
	}

	@Override
	public void publish(Destination destination, String message) {
		jmsTemplate.convertAndSend(destination, message);
	}

}
